package com.minshenglife.zanzan.web.weixin;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.minshenglife.zanzan.web.weixin.service.EMOWXBaseServcie;
import com.minshenglife.zanzan.web.weixin.service.WXAccTokenService;

/**
 * 微信分组管理
 * @author jianghaibo
 *
 */
@Controller
@RequestMapping("/group")
public class EMOGroupManageController {

	Logger log = LoggerFactory.getLogger(MenuController.class);
	@Resource
	WXAccTokenService tokenService;
	//{"group":{"id":100,"name":"内勤"}}
	//{"group":{"id":101,"name":"外勤"}}
	@RequestMapping("/main.do")
	public void addGroup(String groupName,HttpServletRequest request,HttpServletResponse response){
		//{"group":{"name":"test"}}
		try {
			JSONObject jsonGroup = new JSONObject();
			JSONObject jsonName = new JSONObject();
			if(groupName != null && groupName.equals("1")){
				jsonName.put("name", "内勤");
			}else if(groupName != null && groupName.equals("2")){
				jsonName.put("name", "外勤");
			}
			jsonGroup.put("group", jsonName);
			String emowxAccToken = tokenService.getEMOWXAccToken();
			boolean creatUserGroup = EMOWXBaseServcie.creatUserGroup(jsonGroup.toString(), emowxAccToken);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
